/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx.mapper;

import cn.webrx.entity.Book;
import cn.webrx.vo.BookVo;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.cache.decorators.FifoCache;
import org.apache.ibatis.mapping.StatementType;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p></p>
 * <p>Powered by webrx On 2023-04-19 14:56:29</p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@Repository
@CacheNamespace(eviction = FifoCache.class, flushInterval = 60000, size = 1024, readWrite = true)
public interface BookMapper {
    @Select("select * from t_book where id = #{id}")
    public Book queryById(int id);

    @Select("select * from t_book order by id desc")
    public List<Book> list();

    public List<BookVo> show();

    public int add(Book book);

    @Insert("insert into t_book(name,price,author) value(#{name},#{price},#{author})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    public int insert(Map<String, Object> map);

    @Insert("insert into t_book(name,price,author) value(#{name},#{price},#{author})")
    public int save(@Param("name") String name, @Param("price") double price, @Param("author") String author);


    public int deleteById();

    public int deleteById(int id);

    public int count();

    public List<Book> page(Map<String, Object> m);

    public List<Book> pages(Map<String, Object> m, RowBounds rows);


    @Select("select * from t_book")
    public List<Book> query();

    @Select("select * from t_book")
    public List<Book> myByPage();


    public int deleteByName(String name);


    public List<Book> selectAll();

    public List<Book> selectAll(Map<String, Object> map);

    public int myinsert(Map<String, Object> map);

    public int myupdate(Book book);

    public int myup(Map<String, Object> map);


    public List<Book> queryAll();

    public List<Book> queryAll(Map<String, Object> map);


    public List<Book> querys();

    public List<Book> querys(Map<String, Object> map);

    int mysave(Map<String, Object> map);


    int delBy(Map<String, Object> map);

    //@Options(statementType = StatementType.CALLABLE) @Select("call p_show")
    //@Options(statementType = StatementType.CALLABLE) @Select("{call p_show}")
    @Options(statementType = StatementType.CALLABLE)
    @Select("{call p_show()}")
    List<Book> pshow();


    void pcount(Map<String, Object> map);

}
